#pragma once

#include "ParticleRenderer.h"

enum AlignmentMode {
    BB_VIEW,
    BB_LOCAL,
    BB_WORLD
};

class ParticleRendererBillboard : public ParticleRenderer {
public:
    virtual ~ParticleRendererBillboard() {}
    
    virtual void render(double vDeltaTime) override {
        m_pShader->use();
        m_pShader->setVec3("gCameraPos", m_pCamera->Position);
        m_pShader->setMat4("view", m_pCamera->GetViewMatrix());
        m_pShader->setMat4("projection", glm::perspective(glm::radians(45.0f), (float)m_Width / (float)m_Height, 0.1f, 1000.0f));
        m_pShader->setInt("FaceToCamera", m_FaceToCamera);
        if(!glm::all(glm::equal(glm::vec3(0.f), m_UpAxis))) {
            m_pShader->setVec3("UpAxis", m_UpAxis);
        }
        

        m_pShader->setInt("Tex", 0);
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, m_TexID);
        
        glBindVertexArray(m_VAO);
        glDrawArrays(GL_POINTS, 0, 1);
        glBindVertexArray(0);
    }

    void setAlignmentUpAxis(glm::vec3 vAxis) {
        m_UpAxis = vAxis;
    }

private:
    glm::vec3 m_UpAxis = glm::vec3(0, 1, 0);
    int m_FaceToCamera = 0;
};